from rest_framework.serializers import ModelSerializer,PrimaryKeyRelatedField,SerializerMethodField
from category_group.models import *


class CategorySer(ModelSerializer):
    class Meta:
        fields = '__all__'
        model = Category


class GroupSer(ModelSerializer):
    cate_name = SerializerMethodField(read_only=True)

    def get_cate_name(self, obj):
        return obj.cate.name

    class Meta:
        fields = '__all__'
        model = Group
        read_only_fields = ["id", ]







